home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / msdos / css / source / landsat.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-19  |  37.3 KB  |  1,153 lines

  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <glib.h>
  5. #include <strlib.h>
  6. #include "land.h"
  7. #include "init.h"
  8.  
  9. /* #include "..\lib.h" */
  10.  
  11. char  workdir[32];
  12. unsigned char huge WAREA[(long)205824]; /* 512*2+512*400  作業用ワークエリア */
  13.  
  14. void mttl()
  15. {
  16.     line(0,0, 639, 22, PSET, col7, 2, 0xffff);
  17.     line(0,0, 639, 22, PSET, col1, 1, 0xffff);
  18.     symbol_(6, 4, "観測衛星画像解析", 2,1, col0, 0,PSET);
  19.     symbol(472, 4, "Ver. 0.92 by Garnet", 1,2, col0, 0,PSET);
  20.     symbol_(4, 2, "観測衛星画像解析", 2,1, col15,0,PSET);
  21.     symbol(470, 2, "Ver. 0.92 by Garnet", 1,2, col15, 0,PSET);
  22. }
  23.  
  24. /* 作業領域内容表示 */
  25. void waexp()
  26. {
  27. unsigned  ddadr[2];
  28. unsigned char page;
  29. char      buf[30175]; /* (397*152+7)/8*4 */
  30. int x, y, com;
  31. int mx, my;
  32. FILE *fp;
  33. char wname[64], swk[80], swk2[80], swk3[80];
  34. unsigned char headblk[2][512];
  35. size_t  bsize, bn;
  36. int i, j;
  37.  
  38.    x = 60; y = 65;
  39.    page = 0;
  40.    BSETDATAADR(ddadr,  buf);
  41.    GDS_getBlock(ddadr[0],  ddadr[1],  page, x,  y, x+396, y+151);
  42.  
  43.    helpbox( x, y, x+390, y+140, "作業領域概要\x095\x05c示");
  44.                                              /* 表 */
  45.  
  46.    for (i = 1; i <= 3; i++) {
  47.       j = x + 10 + 110*(i-1);   
  48.       sprintf(swk, "作業領域 %1d", i);
  49.       msgset(j, y+25, swk, col0);
  50.  
  51.       /* work area open */
  52.       sprintf(wname, "%s\\warea%1d.lnd", workdir, i);
  53.       if ((fp = fopen(wname, "rb")) == NULL) {
  54.          continue;
  55.       }
  56.       bsize = 512; bn = 1;
  57.       if (fread( headblk[0], bsize, bn, fp) != bn) {
  58.          fclose(fp); continue;
  59.       }
  60.       if (fread( headblk[1], bsize, bn, fp) != bn) {
  61.          fclose(fp); continue;
  62.       }
  63.       strmid(swk, headblk[0]+16, 1, 15); /* original or calc */ 
  64.       msgset2(j, y+45, swk, col0);
  65.       
  66.       sprintf(swk, "[%sL-%sL]", strmid(swk2, headblk[1], 1, 4), strmid(swk3, headblk[1]+4, 1, 4));
  67.       msgset2(j, y+55, swk, col0);
  68.       
  69.       sprintf(swk, "[%sP-%sP]", strmid(swk2, headblk[1]+16, 1, 4), strmid(swk3, headblk[1]+20, 1, 4));
  70.       msgset2(j, y+65, swk, col0);
  71.  
  72.       strmid(swk, headblk[0]+32, 1, 15); /* band num */
  73.       msgset2(j, y+75, swk, col0);
  74.  
  75.       strmid(swk, headblk[1],  89,  7); /* date */
  76.       msgset2( j, y+85, swk, col0);
  77.       strmid(swk, headblk[1],  97,  9); /* wrs seen sentor n */
  78.       msgset2( j, y+95, swk, col0);
  79.       strmid(swk, headblk[1], 106,  7); /* -s */
  80.       msgset2( j+16, y+105, swk, col0);
  81.       strmid(swk, headblk[1], 114,  9); /* wrs 表示 */
  82.       msgset2( j, y+115, swk, col0);
  83.       /* strmid(swk, headblk[1], 176, 13);  nasda landsat */
  84.       /* msgset2( j, y+105, swk, col0); */
  85.       /* strmid(swk, headblk[1], 189, 15); seen id */
  86.       /* msgset2( j, y+105, swk, col0); */
  87.       strmid(swk, headblk[1], 209,  8); /* sensor name */
  88.       msgset2( j, y+125, swk, col0);
  89.       fclose(fp);
  90.    }
  91.  
  92.    recogmsg(x+350, y+115, col0);
  93.    while (1) {
  94.       while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
  95.       if (xychk(mx, my, x+350, y+115, x+350+33, y+115+18) == 1) {
  96.          recogmsg(x+350, y+115, -1);
  97.          while((MOS_rdpos(&mx, &my) & 0x01) == 1);
  98.          if (xychk(mx, my, x+350, y+115, x+350+33, y+115+18) == 0) {
  99.             recogmsg(x+350, y+115, col0);
  100.             continue;
  101.          } else {
  102.             break;
  103.          }
  104.       }
  105.    }
  106.    GDS_putBlock(ddadr[0],  ddadr[1],  page, x,  y, x+396, y+151, PSET);
  107.    return;
  108.  
  109. }
  110.  
  111. void wabot(int x, int y, int sw)
  112. {
  113.     int c1, c2, c4;
  114.  
  115.     if (sw == 0) {
  116.        c1 = col1; c2 = col8; c4 = col7;
  117.     } else {
  118.        c1 = col8; c2 = col8; c4 = col15;
  119.     }
  120.     line(x+2, y+2, x+22, y+22, PSET, col0, 2, 0xffff);
  121.     line(x, y, x+20, y+20, PSET, c4, 2, 0xffff);
  122.     line(x, y, x+20, y+20, PSET, c2, 1, 0xffff);
  123.     symbol(x+2, y+2, "WA", 1, 2, c1, 0, PSET);
  124. }
  125.  
  126. int wabotchk( int mx, int my, int x, int y)
  127. {
  128.  
  129.   if (xychk16(mx, my, x, y) == 1) {
  130.      wabot(x, y, 1);
  131.      while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
  132.      if (xychk16(mx, my, x, y) == 1) waexp();
  133.      wabot(x, y, 0);
  134.      return(1);
  135.   }
  136.   return(0);
  137. }
  138.  
  139.  
  140. /* mouse on off message  if col < 0 then reverse */
  141. /* msg : 2char */
  142. void mousemsg(int x, int y, char *msg, int col)
  143. {
  144.    if (col < 0) {
  145.       line(x-2, y-2, x+33, y+18, PSET, col15, 1, 0xffff);
  146.       line(x-1, y-1, x+32, y+17, PSET, col0,  2, 0xffff);
  147.       msgset(x, y, msg, col15);
  148.    } else {
  149.       line(x-2, y-2, x+33, y+18, PSET, col,  1, 0xffff);
  150.       line(x-1, y-1, x+32, y+17, PSET, col7, 2, 0xffff);
  151.       msgset( x, y, msg, col);
  152.    }
  153. }
  154.  
  155. void execmsg(int x, int y, int col)
  156. {
  157.    if (col < 0) {
  158.       line(x-2, y-2, x+33, y+18, PSET, col15, 1, 0xffff);
  159.       line(x-1, y-1, x+32, y+17, PSET, col0,  2, 0xffff);
  160.       msgset(x, y, "実行", col15);
  161.    } else {
  162.       line(x-2, y-2, x+33, y+18, PSET, col,  1, 0xffff);
  163.       line(x-1, y-1, x+32, y+17, PSET, col7, 2, 0xffff);
  164.       msgset( x, y, "実行", col);
  165.    }
  166. }
  167.  
  168. void dcalcerr(int x, int y, int warea)
  169. {
  170. char  msg[80];
  171.  
  172.    helpcls( x, y, x+390, y+120);
  173.    if ( warea != 0 ) sprintf( msg, "作業領域 %d にエラーが発生しました。", warea);
  174.    else sprintf( msg, "作業領域にエラーが発生しました。");
  175.    msgset(x+16, y+50, msg, col10);
  176.    msgset(x+16, y+70, "確認ボタンを押してください。", col10);
  177.    recogin( x+300, y+90, 0);
  178.    return;
  179. }
  180.  
  181.  
  182. /* com = A, com3 = B, com5 = out, com7 = calc type, abc[3]= work area */
  183. void datacalc2(int com, int com3, int com5, int com7, float abc[])
  184. {
  185. unsigned  ddadr[2];
  186. unsigned  char page;
  187. char      buf[26206]; /* (397*132+7)/8*4 */
  188. int       x, y, erflg = 0;
  189. int       mx, my, mosx=400, mosy=100;
  190. int       i, j, k, cx, cy, col, px, py;
  191. char      swk[80];
  192. char      wname1[64], wname2[64], wname3[64];
  193. FILE      *fp1, *fp2, *fp3;
  194. unsigned  char headblk[2][512], wblk1[1024], wblk2[1024], *blk1, *blk2;
  195. size_t    bsize, bn;
  196. unsigned  char huge *WPTR;
  197. float     a, b, c, wfl;
  198.  
  199.    a = abc[0]; b = abc[1]; c = abc[2];
  200.    sprintf(wname1, "%s\\warea%1d.lnd", workdir, com);
  201.    sprintf(wname2, "%s\\warea%1d.lnd", workdir, com3);
  202.    sprintf(wname3, "%s\\warea%1d.lnd", workdir, com5);
  203.  
  204.    x = 60; y = 100;
  205.    page = 0;
  206.    BSETDATAADR(ddadr,  buf);
  207.    GDS_getBlock(ddadr[0],  ddadr[1],  page, x,  y, x+396, y+131);
  208.  
  209.    helpbox( x, y, x+390, y+120, "演算");
  210.    psmsgcls();
  211.    msgset(96, 315, "画像間の演算処理を実行中です。", col0);
  212.    switch (com7) {
  213.    case   1  : strcpy(swk, "(axA)+(bxB)");  break;
  214.    case   2  : strcpy(swk, "(axA)-(bxB)");  break;
  215.    case   3  : strcpy(swk, "(axA)÷(bxB)"); break;
  216.    case   4  : strcpy(swk, "(axA)x(bxB)");  break;
  217.    case   5  : strcpy(swk, "(axA)+c");  break;
  218.    case   6  : strcpy(swk, "(axA)-c");  break;
  219.    case   7  : strcpy(swk, "(axA)÷c"); break;
  220.    case   8  : strcpy(swk, "(axA)+c");  break;
  221.    default   : strcpy(swk, ""); break;
  222.    }
  223.    msgset(x+32, y+50, swk, col0);
  224.    msgset(x+32, y+80, "計算中! しばらくお待ちください。", col0);
  225.  
  226.    /* work area open */
  227.    if ((fp1 = fopen(wname1, "rb")) == NULL) {
  228.       dcalcerr(x, y, com);
  229.       goto dend;
  230.    }
  231.    bsize = 512; bn = 1;
  232.    if (fread( headblk[0], bsize, bn, fp1) != bn) {
  233.       fclose(fp1); dcalcerr(x, y, com);
  234.       goto dend;
  235.    }
  236.    if (fread( headblk[1], bsize, bn, fp1) != bn) {
  237.       fclose(fp1); dcalcerr(x, y, com);
  238.       goto dend;
  239.    }
  240.  
  241.    if (com7 < 5) {
  242.       if ((fp2 = fopen(wname2, "rb")) == NULL) {
  243.          fclose(fp1); dcalcerr(x, y, com3);
  244.          goto dend;
  245.       }
  246.       bsize = 1024; bn = 1;
  247.       if (fread( wblk1, bsize, bn, fp2) != bn) { /* ヘッダーよみとばし */
  248.          fclose(fp1); fclose(fp2); dcalcerr(x, y, com3);
  249.          goto dend;
  250.       }
  251.    }
  252.    
  253.    WPTR = WAREA;
  254.    bsize = 512; bn = 1;
  255.    for (i = 0; i < 400; i++) {
  256.       /* 残量表示 */
  257.       sprintf(swk, "%d", 400-i);
  258.       line(x+16, y+30, x+48, y+46, PSET, col7, 2, 0xffff);
  259.       symbol_(x+16, y+30, swk, 1, 1, col0, 0, PSET);
  260.    
  261.       blk1 = wblk1; blk2 = wblk2;
  262.       if (fread( wblk1, bsize, bn, fp1) != bn) {
  263.          fclose(fp1); if (com7 < 5) fclose(fp2);
  264.          dcalcerr(x, y, com);
  265.          goto dend;
  266.       }
  267.       if (com7 < 5) {
  268.          if (fread( wblk2, bsize, bn, fp2) != bn) {
  269.             fclose(fp1); fclose(fp2);
  270.             dcalcerr(x, y, com3);
  271.             goto dend;
  272.          }
  273.       }
  274.  
  275.       switch (com7) {
  276.       case   1 :
  277.                for (j = 0; j < 512; j++) {
  278.                   if ((wfl = a*(*(blk1++)) + b*(*(blk2++))) > 255) { *WPTR = 255; erflg = 1; }
  279.                   else if (wfl < 0) { *WPTR = 0; erflg = -1; }
  280.                   else { *WPTR = wfl; }
  281.                   WPTR++;
  282.                }
  283.                break;
  284.       case   2 :
  285.                for (j = 0; j < 512; j++) {
  286.                   if ((wfl = a*(*(blk1++)) - b*(*(blk2++))) > 255) { *WPTR = 255; erflg = 1; }
  287.                   else if (wfl < 0) { *WPTR = 0; erflg = -1; }
  288.                   else { *WPTR = wfl; }
  289.                   WPTR++;
  290.                }
  291.                break;
  292.       case   3 :
  293.                for (j = 0; j < 512; j++) {
  294.                   if ((wfl = a*(*(blk1++)) / b*(*(blk2++))) > 255) { *WPTR = 255; erflg = 1; }
  295.                   else if (wfl < 0) { *WPTR = 0; erflg = -1; }
  296.                   else { *WPTR = wfl; }
  297.                   WPTR++;
  298.                }
  299.                break;
  300.       case   4 :
  301.                for (j = 0; j < 512; j++) {
  302.                   if ((wfl = a*(*(blk1++)) * b*(*(blk2++))) > 255) { *WPTR = 255; erflg = 1; }
  303.                   else if (wfl < 0) { *WPTR = 0; erflg = -1; }
  304.                   else { *WPTR = wfl; }
  305.                   WPTR++;
  306.                }
  307.                break;
  308.       case   5 :
  309.                for (j = 0; j < 512; j++) {
  310.                   if ((wfl = a*(*(blk1++)) + c) > 255) { *WPTR = 255; erflg = 1; }
  311.                   else if (wfl < 0) { *WPTR = 0; erflg = -1; }
  312.                   else { *WPTR = wfl; }
  313.                   WPTR++;
  314.                }
  315.                break;
  316.       case   6 :
  317.                for (j = 0; j < 512; j++) {
  318.                   if ((wfl = a*(*(blk1++)) - c) > 255) { *WPTR = 255; erflg = 1; }
  319.                   else if (wfl < 0) { *WPTR = 0; erflg = -1; }
  320.                   else { *WPTR = wfl; }
  321.                   WPTR++;
  322.                }
  323.                break;
  324.       case   7 :
  325.                for (j = 0; j < 512; j++) {
  326.                   if ((wfl = a*(*(blk1++)) / c) > 255) { *WPTR = 255; erflg = 1; }
  327.                   else if (wfl < 0) { *WPTR = 0; erflg = -1; }
  328.                   else { *WPTR = wfl; }
  329.                   WPTR++;
  330.                }
  331.                break;
  332.       case   8 :
  333.                for (j = 0; j < 512; j++) {
  334.                   if ((wfl = a*(*(blk1++)) * c) > 255) { *WPTR = 255; erflg = 1; }
  335.                   else if (wfl < 0) { *WPTR = 0; erflg = -1; }
  336.                   else { *WPTR = wfl; }
  337.                   WPTR++;
  338.                }
  339.                break;
  340.       default  :
  341.                erflg = 9;
  342.                *WPTR = 0;
  343.                WPTR++;
  344.                break;
  345.       }
  346.    }
  347.    /* 計算終了 */
  348.    fclose(fp1);
  349.    if (com7 < 5) fclose(fp2);
  350.    
  351.    helpcls( x, y, x+390, y+120);
  352.    if (erflg == 0) {
  353.       msgset(x+16, y+30, "計算が正常に終了しました。", col0);
  354.    } else {
  355.       msgset(x+16, y+25, "計算が終了しました。計算結果データ中に", col0);
  356.       msgset(x+16, y+45, "[0~255] の範囲を越えたものがあります。", col0);
  357.    }
  358.    if (recogin(x+300, y+95, 1) == 0) { /* 確認のときはcom5の作業領域にデータ格納 */
  359.       msgset(x+16, y+65, "データを登録中です。お待ちください。", col0);
  360.       /* work area open */
  361.       if ((fp3 = fopen(wname3, "w+b")) == NULL) {
  362.          fclose(fp3); dcalcerr(x, y, com5);
  363.          goto dend;
  364.       }
  365.  
  366.       switch (com7) {
  367.       case   1  : strcpy(swk, "(axA)+(bxB)");  break;
  368.       case   2  : strcpy(swk, "(axA)-(bxB)");  break;
  369.       case   3  : strcpy(swk, "(axA)÷(bxB)"); break;
  370.       case   4  : strcpy(swk, "(axA)x(bxB)");  break;
  371.       case   5  : strcpy(swk, "(axA)+c");  break;
  372.       case   6  : strcpy(swk, "(axA)-c");  break;
  373.       case   7  : strcpy(swk, "(axA)÷c"); break;
  374.       case   8  : strcpy(swk, "(axA)+c");  break;
  375.       default   : strcpy(swk, ""); break;
  376.       }
  377.  
  378.       WPTR = WAREA;
  379.       bsize = 512; bn = 1;
  380.       /* header write */
  381.       sprintf( headblk[0]+16, swk);
  382.       bsize = 512; bn = 1;
  383.       if (fwrite( headblk[0], bsize, bn, fp3) != bn) {
  384.          fclose(fp3); dcalcerr(x, y, com5);
  385.          goto dend;
  386.       }
  387.       if (fwrite( headblk[1], bsize, bn, fp3) != bn) {
  388.          fclose(fp3); dcalcerr(x, y, com5);
  389.          goto dend;
  390.       }
  391.       
  392.       for ( i = 0; i < 400; i++) {
  393.          for (j = 0; j < 512; j++) {
  394.             wblk1[j] = *WPTR; WPTR++;
  395.          }
  396.          if (fwrite( wblk1, bsize, bn, fp3) != bn) {
  397.             fclose(fp3); dcalcerr(x, y, com5);
  398.             goto dend;
  399.          }
  400.       }
  401.       fclose(fp3);
  402.    }
  403.    
  404. dend:
  405.    GDS_putBlock(ddadr[0],  ddadr[1],  page, x,  y, x+396, y+131, PSET);
  406.    return;
  407. }
  408.  
  409. void datacalcu()
  410. {
  411. int bcl[16];
  412. int exec, com, com2, com3, com4, com5, com6, com7, com8;
  413. int mx, my, mosx=400, mosy=100;
  414. int cx2, cy2;
  415. unsigned char page;
  416. double  wa;
  417. float   abc[3];
  418. char    swk[80];
  419. int  i;
  420.  
  421. com  = com2 = 1;
  422. com3 = com4 = 1;
  423. com5 = com6 = 1;
  424. com7 = com8 = 1;
  425. abc[0] = abc[1] = abc[2] = 1;
  426.  
  427.  
  428.    page = 1;
  429.    GDS_displayPage(page);
  430.    gout();
  431.    page = 0;
  432.    GDS_writePage(page);
  433.    gout();
  434.  
  435.       Cls;
  436.       mttl();
  437.       bcl[0] = col1;
  438.       paint(1,30, 1, col7,  1, bcl);
  439.       menubox( 80, 40, 560, 280, "画像間  四則演算");
  440.       helpbox( 90, 65, 220, 150, "画像 A");
  441.       helpbox(240, 65, 370, 150, "画像 B");
  442.       helpbox(390, 65, 520, 150, "結果登録先");
  443.       helpbox( 80,290, 560, 360, "メッセージ");
  444.       msgset( 90, 90, " ○ 作業領域1", col0);
  445.       msgset( 90,110, " ○ 作業領域2", col0);
  446.       msgset( 90,130, " ○ 作業領域3", col0);
  447.       msgset(240, 90, " ○ 作業領域1", col0);
  448.       msgset(240,110, " ○ 作業領域2", col0);
  449.       msgset(240,130, " ○ 作業領域3", col0);
  450.       msgset(390, 90, " ○ 作業領域1", col0);
  451.       msgset(390,110, " ○ 作業領域2", col0);
  452.       msgset(390,130, " ○ 作業領域3", col0);
  453.  
  454.       msgset( 80,160, " ○ (a×A)+(b×B)", col0);
  455.       msgset( 80,180, " ○ (a×A)-(b×B)", col0);
  456.       msgset( 80,200, " ○ (a×A)÷(b×B)", col0);
  457.       msgset( 80,220, " ○ (a×A)×(b×B)", col0);
  458.       msgset(320,160, " ○ (a×A)+c", col0);
  459.       msgset(320,180, " ○ (a×A)-c", col0);
  460.       msgset(320,200, " ○ (a×A)÷c", col0);
  461.       msgset(320,220, " ○ (a×A)×c", col0);
  462.       msgset2( 80,240, " a=", col0);
  463.       msgset2(112,240, "[          ]", col12);
  464.       msgset2( 80,250, " b=", col0);
  465.       msgset2(112,250, "[          ]", col12);
  466.       msgset2( 80,260, " c=", col0);
  467.       msgset2(112,260, "[          ]", col12);
  468.       for (i = 0; i < 3; i++) {
  469.          sprintf( swk, "%8.3f", abc[i]);
  470.          msgset2( 128, 240+i*10, swk , col0);
  471.       }
  472.       msgset(320,240, " ○ 終 了", col0);
  473.       execmsg(480, 260, col0);
  474.       calcu(600, 30, 0);
  475.       wabot(600, 60, 0);
  476.       
  477.       GDS_displayPage(page);
  478.       gout();
  479.       locate(0,0,COFF);
  480.       MOS_disp(0);
  481.       exec = 0;
  482.       
  483.       while(1) {
  484.          if (com  == 1) msgset(106, 90, "●", col0);
  485.          if (com  == 2) msgset(106,110, "●", col0);
  486.          if (com  == 3) msgset(106,130, "●", col0);
  487.          if (com3 == 1) msgset(256, 90, "●", col0);
  488.          if (com3 == 2) msgset(256,110, "●", col0);
  489.          if (com3 == 3) msgset(256,130, "●", col0);
  490.          if (com5 == 1) msgset(406, 90, "●", col0);
  491.          if (com5 == 2) msgset(406,110, "●", col0);
  492.          if (com5 == 3) msgset(406,130, "●", col0);
  493.          if (com7 == 1) msgset( 96,160, "●", col0);
  494.          if (com7 == 2) msgset( 96,180, "●", col0);
  495.          if (com7 == 3) msgset( 96,200, "●", col0);
  496.          if (com7 == 4) msgset( 96,220, "●", col0);
  497.          if (com7 == 5) msgset(336,160, "●", col0);
  498.          if (com7 == 6) msgset(336,180, "●", col0);
  499.          if (com7 == 7) msgset(336,200, "●", col0);
  500.          if (com7 == 8) msgset(336,220, "●", col0);
  501.          if (com7 == 9) msgset(336,240, "●", col0);
  502.          
  503.          psmsgcls();
  504.          if (com7 != 9) {
  505.             msgset(96, 315, "画像データ(作業領域)間の四則演算をします。", col0);
  506.             msgset(96, 335, "演算方法と定数を決定してから実行してください。", col0);
  507.          } else {
  508.             msgset(96, 315, "メイン・メニューにもどります。", col0);
  509.          }
  510.  
  511.          while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
  512.          if (calchk(mx, my, 600, 30, &mosx, &mosy) == 1) continue;
  513.          if (wabotchk(mx, my, 600, 60) == 1) continue;
  514.          
  515.          for (i = 0; i < 3; i++) {
  516.             if (xychk(mx, my,120,240+i*10, 120+80, 240+10+i*10) == 1) {
  517.                line( 120, 240+i*10-1, 120+80, 240+10+i*10, PSET, col14, 1, 0xffff);
  518.                cx2 = 250; cy2 = 125;
  519.                psmsgcls();
  520.                sprintf(swk, "定数 %c の値を入力してぐださい。", 'a'+i);
  521.                msgset(96, 315, swk, col0);
  522.                if (calc( &cx2, &cy2, &wa) == 1) {
  523.                   abc[i] = wa;
  524.                   sprintf( swk, "%8.3f", abc[i]);
  525.                   line( 120, 240+i*10-1, 120+80, 240+10+10*i, PSET, col7, 2, 0xffff);
  526.                   msgset2( 128, 240+i*10, swk , col0);
  527.                } else {
  528.                   line( 120, 240+i*10-1, 120+80, 240+10+10*i, PSET, col7, 1, 0xffff);
  529.                }
  530.                psmsgcls();
  531.                break;
  532.             }
  533.          }
  534.          
  535.          for (i = 0; i < 3; i++) {
  536.             if (xychk16(mx, my, 106, 90+i*20) == 1) com  = i+1;
  537.          }
  538.          for (i = 0; i < 3; i++) {
  539.             if (xychk16(mx, my, 256, 90+i*20) == 1) com3 = i+1;
  540.          }
  541.          for (i = 0; i < 3; i++) {
  542.             if (xychk16(mx, my, 406, 90+i*20) == 1) com5 = i+1;
  543.          }
  544.          for (i = 0; i < 4; i++) {
  545.             if (xychk16(mx, my,  96, 160+i*20) == 1) com7 = i+1;
  546.          }
  547.          for (i = 0; i < 5; i++) {
  548.             if (xychk16(mx, my, 336, 160+i*20) == 1) com7 = i+5;
  549.          }
  550.  
  551.          if (xychk(mx, my,480, 260, 480+33, 260+18) == 1) {
  552.             execmsg(480, 260, -1);
  553.             while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
  554.             if (xychk(mx, my,480, 260, 480+33, 260+18) == 1) { /* 実行 */
  555.                if (com7 != 9) {
  556.                   datacalc2(com, com3, com5, com7, abc); /* commnad,  */
  557.                } else { return; }
  558.             }
  559.             execmsg(480, 260, col0);
  560.             continue;
  561.          }
  562.          
  563.          if (com != com2) {
  564.             msgset(106, 90+(com2-1)*20, "●", col7);
  565.             msgset(106, 90+(com2-1)*20, "○", col0);
  566.             com2 = com;
  567.          }
  568.          
  569.          if (com3 != com4) {
  570.             msgset(256, 90+(com4-1)*20, "●", col7);
  571.             msgset(256, 90+(com4-1)*20, "○", col0);
  572.             com4 = com3;
  573.          }
  574.          
  575.          if (com5!= com6) {
  576.             msgset(406, 90+(com6-1)*20, "●", col7);
  577.             msgset(406, 90+(com6-1)*20, "○", col0);
  578.             com6 = com5;
  579.          }
  580.          
  581.          if (com7!= com8) {
  582.             if (com8 < 5) {
  583.                msgset( 96, 160+(com8-1)*20, "●", col7);
  584.                msgset( 96, 160+(com8-1)*20, "○", col0);
  585.             } else {
  586.                msgset(336, 160+(com8-5)*20, "●", col7);
  587.                msgset(336, 160+(com8-5)*20, "○", col0);
  588.             }
  589.             com8 = com7;
  590.          }
  591.       }
  592. }
  593.  
  594.  
  595. void hstmsg(int com)
  596. {
  597. char hmsg1[80], hmsg2[80];
  598. int col;
  599.  
  600.    hmsg1[0] = '\0'; hmsg2[0] = '\0';
  601.  
  602.    if (com == 7) {
  603.       strcpy(hmsg1, "ヒストグラム\x095\x05c示をします。");
  604.                                      /* 表 */
  605.       strcpy(hmsg2, "作業領域を設定してください。");
  606.    }
  607.  
  608.    if (com == 8) {
  609.       strcpy(hmsg1, "1/4画像(256ピクセル×200ライン)のヒストグラム\x095\x05c示をします。");
  610.                                                             /* 表 */
  611.       strcpy(hmsg2, "作業領域と画像\x095\x05c示開始点を設定してください。");
  612.    }                     /* 表 */
  613.  
  614.    if (com == 10) {
  615.       strcpy(hmsg1, "メイン・メニューにもどります。");
  616.    }
  617.  
  618.    if (com == 21) {
  619.       strcpy(hmsg1, "ライン開始点を設定してください。[ 1 ~ 201 ]");
  620.    }
  621.  
  622.    if (com == 22) {
  623.       strcpy(hmsg1, "ピクセル開始点を設定してください。[ 1 ~ 257 ]");
  624.    }
  625.    msgset(96, 315, hmsg1, col0);
  626.    msgset(96, 335, hmsg2, col0);
  627. }
  628.  
  629. void hststart(int lin, int pixel)
  630. {
  631. char  swk[80];
  632. int x = 260, y = 200;
  633.  
  634.    helpbox( x, y, x+130, y+70, "\x095\x05c示開始点設定");
  635.                                 /* 表 */
  636.    sprintf( swk, "%4d ライン", lin);
  637.    msgset( x+20, y+30, swk , col0);
  638.    sprintf( swk, "%4d ピクセル", pixel);
  639.    msgset( x+20, y+50, swk , col0);
  640. }
  641.  
  642. void histgram2( int warea, int lin, int pixel, int mlin, int mpixel)
  643. {
  644. unsigned char page;
  645. int     i, j, mx, my;
  646. char    wname1[80];
  647. unsigned char    headblk[2][512], wblk[512];
  648. size_t  bsize, bn;
  649. FILE    *fp1;
  650. char    swk[80];
  651. long    hstcnt[256], hstmax;
  652. int     px, py;
  653.  
  654.    sprintf(wname1, "%s\\warea%1d.lnd", workdir, warea);
  655.  
  656.    page = 1;
  657.    GDS_writePage(page);
  658.    gout();
  659.    Cls;
  660.  
  661.    helpbox2( 0, 0, 639, 109, "ヒストグラム\x095\x05c示");
  662.                                           /* 表 */
  663.    line( 0, 0, 639, 399, PSET, col1, 1, 0xffff);
  664.    /* work area open */
  665.    if ((fp1 = fopen(wname1, "rb")) == NULL) {
  666.       GDS_displayPage(page);
  667.       gout();
  668.       pseudeerr(warea);
  669.       goto end;
  670.    }
  671.    bsize = 512; bn = 1;
  672.    if (fread( headblk[0], bsize, bn, fp1) != bn) {
  673.       GDS_displayPage(page);
  674.       gout();
  675.       fclose(fp1); pseudeerr(warea); goto end;
  676.    }
  677.    if (fread( headblk[1], bsize, bn, fp1) != bn) {
  678.       GDS_displayPage(page);
  679.       gout();
  680.       fclose(fp1); pseudeerr(warea); goto end;
  681.    }
  682.    sprintf(swk, "作業領域 %1d", warea);
  683.    msgset(10,  25, swk, col0);
  684.    strmid(swk, headblk[0]+16, 1, 15);
  685.    msgset2(10, 45, swk, col0);
  686.    
  687.    sprintf(swk, "%dライン-%dピクセル/", lin, pixel);
  688.    msgset2(10, 55, swk, col0);
  689.    sprintf(swk, " %dライン-%dピクセル", lin+mlin-1, pixel+mpixel-1);
  690.    msgset2(10, 65, swk, col0);
  691.    
  692.    strmid(swk, headblk[0]+32, 1, 15); /* band num */
  693.    msgset2(10, 75, swk, col0);
  694.  
  695.    strmid(swk, headblk[1],  89,  7); /* date */
  696.    msgset2(180, 25, swk, col0);
  697.    strmid(swk, headblk[1],  97,  16); /* wrs seen sentor n-s */
  698.    msgset2(180, 35, swk, col0);
  699.    strmid(swk, headblk[1], 114,  9); /* wrs 表示 */
  700.    msgset2(180, 45, swk, col0);
  701.    strmid(swk, headblk[1], 176, 13); /* nasda landsat */
  702.    msgset2(180, 55, swk, col0);
  703.    strmid(swk, headblk[1], 189, 15); /* seen id */
  704.    msgset2(180, 65, swk, col0);
  705.    strmid(swk, headblk[1], 209,  8); /* sensor name */
  706.    msgset2(180, 75, swk, col0);
  707.  
  708.    page = 1;
  709.    GDS_displayPage(page);
  710.    gout();
  711.  
  712.    msgset(25, 200, "頻", col14);
  713.    msgset(25, 230, "度", col14);
  714.    msgset(25-8, 260, "[%]", col14);
  715.    msgset(25, 290, "↑", col14);
  716.    msgset(10, 345, "強度→", col14);
  717.    line( 75, 140, 600, 340, PSET, col13, 1, 0xffff);
  718.    for (i = 0; i <= 250; i+=10) {
  719.      line( 80+i*2, 340, 80+i*2, 340+3, PSET, col13, 0, 0xffff);
  720.      sprintf(swk, "%3d", i);
  721.      symbol(84+i*2, 340+5, swk, 1,1, col13, 3 ,PSET);
  722.     /* line( 80+i*2, 140, 80+i*2, 140-3, PSET, col13, 0, 0xffff); */
  723.    }
  724.    line( 80+512, 340, 80+512, 340+3, PSET, col13, 0, 0xffff);
  725.    symbol(84+255*2, 340+5, "255", 1,1, col13, 3, PSET);
  726.    for (i = 0; i <= 100; i+=10) {
  727.       line( 75, 340-i*2, 78, 340-i*2, PSET, col13, 0, 0xffff);
  728.       line( 600, 340-i*2, 600-3, 340-i*2, PSET, col13, 0, 0xffff);
  729.       sprintf(swk, "%3d", i);
  730.       symbol(48, 340-4-i*2, swk, 1,1, col13, 0, PSET);
  731.    }
  732.    
  733.    
  734.    bsize = 512; bn = 1;
  735.    if ((lin-1) != 0) {
  736.       fseek(fp1, (long)(512.*(lin-1)), SEEK_CUR);
  737.    }
  738.    for (i = 0; i < 256; i++) hstcnt[i] = 0;
  739.    for (py = lin; py < lin+mlin; py++) {
  740.       if (fread( wblk, bsize, bn, fp1) != bn) {
  741.          fclose(fp1);
  742.          pseudeerr(0); goto end;
  743.       }
  744.       
  745.       for (px = (pixel-1); px < pixel-1+mpixel; px++) {
  746.          hstcnt[ wblk[px] ]++; 
  747.       }
  748.    }
  749.    fclose(fp1);
  750.    
  751.    hstmax = 0;
  752.    for (i = 0; i < 256; i++) {
  753.       if (hstmax < hstcnt[i]) hstmax = hstcnt[i];
  754.    }
  755.    
  756.    for (i = 0; i < 256; i++) {
  757.       j = 100. * hstcnt[i] / hstmax;
  758.       line( 80+i*2, 340, 80+i*2, 340-j*2, OR, col5, 0, 0xffff);
  759.    }
  760.  
  761.    while (recogin(550, 85, 0) != 0); /* 確認 */
  762.  
  763. end:;
  764.    page = 0;
  765.    GDS_displayPage(page);
  766.    gout();
  767.    line( 550-2, 85-2, 550+40, 85+20, PSET, col7, 2, 0xffff); /* 確認メッセージ消去 */
  768.    GDS_writePage(page);
  769.    gout();
  770.    return;
  771. }
  772.  
  773.  
  774. void histgram()
  775. {
  776. int bcl[16];
  777. int exec, com, com2, com3, com4;
  778. int mx, my, mosx=400, mosy=100;
  779. int cx2, cy2;
  780. unsigned char page;
  781. int  lin = 1, pixel = 1, mlin, mpixel;
  782. double  wa;
  783. char    swk[80];
  784.  
  785. com  = com2 = 7;
  786. com3 = com4 = 1;
  787.  
  788. start:
  789.    page = 1;
  790.    GDS_displayPage(page);
  791.    gout();
  792.    page = 0;
  793.    GDS_writePage(page);
  794.    gout();
  795.  
  796.       Cls;
  797.       mttl();
  798.       bcl[0] = col1;
  799.       paint(1,30, 1, col7,  1, bcl);
  800.       menubox( 80, 40, 560, 280, "ヒストグラム\x095\x05c示条件設定");
  801.                                               /* 表 */
  802.       helpbox( 80,290, 560, 360, "メッセージ");
  803.       msgset( 80, 70, " ○ 作業領域1", col0);
  804.       msgset( 80, 90, " ○ 作業領域2", col0);
  805.       msgset( 80,110, " ○ 作業領域3", col0);
  806.       msgset(320, 70, " ○ ヒストグラム\x095\x05c示", col0);
  807.                                          /* 表 */
  808.       msgset(320, 90, " ○ ヒストグラム\x095\x05c示(1/4)", col0);
  809.                                          /* 表 */
  810.       msgset(320,130, " ○ 終 了", col0);
  811.       execmsg(480, 190, col0);
  812.       if (com == 8) hststart(lin, pixel);
  813.       calcu(600, 30, 0);
  814.       wabot(600, 60, 0);
  815.       GDS_displayPage(page);
  816.       gout();
  817.       locate(0,0,COFF);
  818.       MOS_disp(0);
  819.       exec = 0;
  820.  
  821.       while(1) {
  822.          if (com3 == 1) msgset( 96, 70, "●", col0);
  823.          if (com3 == 2) msgset( 96, 90, "●", col0);
  824.          if (com3 == 3) msgset( 96,110, "●", col0);
  825.          if (com  == 7) msgset(336, 70, "●", col0);
  826.          if (com  == 8) msgset(336, 90, "●", col0);
  827.          if (com  ==10) msgset(336,130, "●", col0);
  828.          hstmsg(com);
  829.  
  830.          if (exec == 1) {
  831.             if (com == 7 || com == 8) {
  832.                if (com == 7) {
  833.                   lin = 1; pixel = 1; mlin = 400; mpixel = 512;
  834.                } else {
  835.                   mlin = 200; mpixel = 256;
  836.                }
  837.                histgram2(com3, lin, pixel, mlin, mpixel); /* commnad, work area, start line, start pixel, max line, max pixel */
  838.                execmsg(480, 190, col0);
  839.                psmsgcls();
  840.                exec = 0;
  841.                continue;
  842.             }
  843.             if (com == 10) { return; }
  844.          }
  845.          while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
  846.          if (calchk(mx, my, 600, 30, &mosx, &mosy) == 1) continue;
  847.          if (wabotchk(mx, my, 600, 60) == 1) continue;
  848.          if ((xychk(mx, my,280-2,230-2, 280+33, 230+18) == 1) && com != 7) {
  849.             line( 280-2,230-2, 280+33, 230+18, PSET, col14, 1, 0xffff);
  850.             cx2 = 105; cy2 = 125;
  851.             psmsgcls();
  852.             hstmsg(21);
  853.             wa = lin;
  854.             if (calc( &cx2, &cy2, &wa) == 1) {
  855.                if (wa <  1 ) lin = 1;
  856.                else if (wa > 201) lin = 201;
  857.                else lin = wa;
  858.                sprintf( swk, "%4d", lin);
  859.                line( 280-2,230-2, 280+33, 230+18, PSET, col7, 2, 0xffff);
  860.                msgset( 280, 230, swk , col0);
  861.             } else {
  862.                line( 280-2,230-2, 280+33, 230+18, PSET, col7, 1, 0xffff);
  863.             }
  864.             psmsgcls();
  865.          }
  866.          if ((xychk(mx, my,280-2,250-2, 280+33, 250+18) == 1) && com != 7) {
  867.             line( 280-2,250-2, 280+33, 250+18, PSET, col14, 1, 0xffff);
  868.             cx2 = 105; cy2 = 125;
  869.             psmsgcls();
  870.             dithmsg(22, 1);
  871.             wa = pixel;
  872.             if (calc( &cx2, &cy2, &wa) == 1) {
  873.                if (wa <  1 ) pixel = 1;
  874.                else if (wa > 257) pixel = 257;
  875.                else pixel = wa;
  876.                sprintf( swk, "%4d", pixel);
  877.                line( 280-2,250-2, 280+33, 250+18, PSET, col7, 2, 0xffff);
  878.                msgset( 280, 250, swk , col0);
  879.             } else {
  880.                line( 280-2,250-2, 280+33, 250+18, PSET, col7, 1, 0xffff);
  881.             }
  882.             psmsgcls();
  883.          }
  884.          
  885.          if (xychk16(mx, my, 96, 70) == 1) com3 = 1;
  886.          if (xychk16(mx, my, 96, 90) == 1) com3 = 2;
  887.          if (xychk16(mx, my, 96,110) == 1) com3 = 3;
  888.          if (xychk16(mx, my,336, 70) == 1) com  = 7;
  889.          if (xychk16(mx, my,336, 90) == 1) com  = 8;
  890.          if (xychk16(mx, my,336,130) == 1) com  =10;
  891.          if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
  892.             execmsg(480, 190, -1);
  893.             while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
  894.             if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
  895.                exec = 1;
  896.                continue;
  897.             } else {
  898.                exec = 0;
  899.                execmsg(480, 190, col0);
  900.                continue;
  901.             }
  902.          }
  903.          if (com3 != com4) {
  904.             if (com4 == 1) { msgset( 96, 70, "●", col7); msgset( 96, 70, "○", col0); }
  905.             if (com4 == 2) { msgset( 96, 90, "●", col7); msgset( 96, 90, "○", col0); }
  906.             if (com4 == 3) { msgset( 96,110, "●", col7); msgset( 96,110, "○", col0); }
  907.             com4 = com3;
  908.          }
  909.          if (com != com2) {
  910.             if (com2 == 7) { msgset(336, 70, "●", col7); msgset(336, 70, "○", col0); }
  911.             if (com2 == 8) { msgset(336, 90, "●", col7); msgset(336, 90, "○", col0); }
  912.             if (com2 ==10) { msgset(336,130, "●", col7); msgset(336,130, "○", col0); }
  913.             if (com  == 7) line( 260,200, 390+10, 270+8, PSET, col7, 2, 0xffff);
  914.             if (com  == 8) hststart(lin, pixel);
  915.             psmsgcls();
  916.             com2 = com;
  917.          }
  918.          /* 裏画面表示 */
  919.          backexp(mx, my,  630, 0, 639, 20);
  920.          continue;
  921.       }
  922. }
  923.  
  924. /*  no operation */
  925. void nop()
  926. {
  927. unsigned  ddadr[2];
  928. unsigned char page;
  929. char      buf[30175]; /* (397*152+7)/8*4 */
  930. int x, y, com;
  931. int mx, my;
  932.  
  933.    x = 60; y = 65;
  934.    page = 0;
  935.    BSETDATAADR(ddadr,  buf);
  936.    GDS_getBlock(ddadr[0],  ddadr[1],  page, x,  y, x+396, y+151);
  937.  
  938.    helpbox( x, y, x+390, y+120, "NOP・メニュー");
  939.    msgset(x, y+50, "     まだ何もないよ!", col0);
  940.    
  941.    recogmsg(x+350, y+95, col0);
  942.    while (1) {
  943.       while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
  944.       if (xychk(mx, my, x+350, y+95, x+350+33, y+95+18) == 1) {
  945.          recogmsg(x+350, y+95, -1);
  946.          while((MOS_rdpos(&mx, &my) & 0x01) == 1);
  947.          if (xychk(mx, my, x+350, y+95, x+350+33, y+95+18) == 0) {
  948.             recogmsg(x+350, y+95, col0);
  949.             continue;
  950.          } else {
  951.             break;
  952.          }
  953.       }
  954.    }
  955.    GDS_putBlock(ddadr[0],  ddadr[1],  page, x,  y, x+396, y+151, PSET);
  956.    return;
  957.  
  958. }
  959.  
  960. void hmsgset(int com, int sw)
  961. {
  962.    char hmsg1[80], hmsg2[80];
  963.    int col;
  964.  
  965.    hmsg1[0] = '\0'; hmsg2[0] = '\0';
  966.    
  967.    if (com == 0) {
  968.       strcpy(hmsg1, "本プログラムを終了します。");
  969.       strcpy(hmsg2, "失われるデータがあるか、確認して下さい。");
  970.    }
  971.  
  972.    if (com == 11) {
  973.       strcpy(hmsg1, "MS-DOSモードになります。");
  974.       strcpy(hmsg2, "EXIT〔改行〕で戻ります。");
  975.    }
  976.    
  977.    if (com == 1) {
  978.       strcpy(hmsg1, "観測データ・フロッピー(IBMフォーマット)から");
  979.       strcpy(hmsg2, "作業領域へデータを読み込みます。");
  980.    }
  981.    
  982.    if (com == 2) {
  983.       strcpy(hmsg1, "作業領域内のデータを退避または復帰します。");
  984.    }
  985.  
  986.    if (com == 3) {
  987.       strcpy(hmsg1, "作業領域内のデータ間で各種の演算処理をします。");
  988.    }
  989.  
  990.    if (com == 4) {
  991.       strcpy(hmsg1, "作業領域内のデータをヒストグラム\x095\x05c示します。");
  992.    }                                                 /* 表 */
  993.  
  994.    if (com == 5) {
  995.       strcpy(hmsg1, "作業領域内のデータをシュード・カラー画像\x095\x05c示します。");
  996.    }                                                        /* 表 */
  997.    
  998.    if (com == 6) {
  999.       strcpy(hmsg1, "作業領域内のデータをディザ・カラー画像\x095\x05c示します。");
  1000.    }                                                      /* 表 */
  1001.  
  1002.    if (com == 7) {
  1003.       strcpy(hmsg1, "拡張用です。");
  1004.    }
  1005.  
  1006.    if (sw == 0) col = col7;
  1007.    else         col = col0;
  1008.    
  1009.    msgset(96, 255, hmsg1, col);
  1010.    msgset(96, 275, hmsg2, col);
  1011. }
  1012.  
  1013. /*  ex.    landsat [a:] [1]         */
  1014. main(int argc, char *argv[])
  1015. {
  1016. int datadrive;
  1017. int x, y, bcl[16];
  1018. int mx, my, com, com2, exec, mosx=400, mosy=100;
  1019. unsigned char page;
  1020. double   wa = 0;
  1021. int i;
  1022.  
  1023.    strcpy( workdir, "a:");
  1024.    datadrive = 1;
  1025.    
  1026.    /* work dir or data drive set */
  1027.    for ( i=1; i < argc; i++) {
  1028.       ++argv;
  1029.       if (( 'a' <= **argv && **argv <= 'z') || ( 'A' <= **argv && **argv <= 'Z')) {
  1030.          strcpy( workdir, *argv);
  1031.       }
  1032.       if ( '0' <= **argv && **argv <= '3') {
  1033.          datadrive = atoi( *argv);
  1034.       }
  1035.    }
  1036.  
  1037.    init();
  1038.    color(7, 0);
  1039.    Cls;
  1040. /*
  1041.    system("tifl land");
  1042. */
  1043. /*
  1044.    printf("%d\n", tiffl(0,0, "land2.tif"));
  1045. */
  1046.    com = 1; com2 = com;
  1047.    while(1) {
  1048.       page = 1;
  1049.       GDS_writePage(page);
  1050.       gout();
  1051.       Cls;
  1052.       GDS_displayPage(page);
  1053.       gout();
  1054.       page = 0;
  1055.       GDS_writePage(page);
  1056.       gout();
  1057.       Cls;
  1058.       mttl();
  1059.       bcl[0] = col1;
  1060.       paint(1,30, 1, col7,  1, bcl);
  1061.       menubox( 80, 40, 560, 220, "メインメニュー");
  1062.       helpbox( 80,230, 560, 300, "コマンド説明");
  1063.  
  1064.       msgset( 80, 70, " ○ データ読み込み", col0);
  1065.       msgset( 80, 90, " ○ 作業領域の退避・復帰", col0);
  1066.       msgset( 80,110, " ○ 画像間  四則演算", col0);
  1067.       msgset( 80,130, " ○ ヒストグラム\x095\x05c示", col0);
  1068.                                               /* 表 */
  1069.       msgset( 80,150, " ○ シュードカラー画像\x095\x05c示", col0);
  1070.                                                     /* 表 */
  1071.       msgset( 80,170, " ○ ディザカラー画像\x095\x05c示", col0);
  1072.                                                /* 表 */
  1073.       /* msgset(320, 70, " ○ 三次元画像\x095\x05c示", col0); */
  1074.                                      /* 表 */
  1075.       msgset(320, 70, " ○ * * *", col0);
  1076.       msgset(320,150, " ○ MS-DOS", col0);
  1077.       msgset(320,170, " ○ 終 了", col0);
  1078.       execmsg(480, 190, col0);
  1079.       calcu(600, 30, 0);
  1080.       wabot(600, 60, 0);
  1081.       exec = 0;
  1082.       GDS_displayPage(page);
  1083.       gout();
  1084.       locate(0,0,COFF);
  1085.       MOS_disp(0);
  1086.       while(1) {
  1087.          if (com  == 1) msgset( 96, 70, "●", col0);
  1088.          if (com  == 2) msgset( 96, 90, "●", col0);
  1089.          if (com  == 3) msgset( 96,110, "●", col0);
  1090.          if (com  == 4) msgset( 96,130, "●", col0);
  1091.          if (com  == 5) msgset( 96,150, "●", col0);
  1092.          if (com  == 6) msgset( 96,170, "●", col0);
  1093.          if (com  == 7) msgset(336, 70, "●", col0);
  1094.          if (com  ==11) msgset(336,150, "●", col0);
  1095.          if (com  == 0) msgset(336,170, "●", col0);
  1096.          hmsgset(com, 1);
  1097.          while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
  1098.          if (exec == 1) {
  1099.             if (com == 1) { dataset(datadrive); break; }
  1100.             if (com == 2) { datasave();  break; }
  1101.             if (com == 3) { datacalcu(); break; }
  1102.             if (com == 4) { histgram();  break; }
  1103.             if (com == 5) { pseude();    break; }
  1104.             if (com == 6) { dither();    break; }
  1105.             if (com == 7) {
  1106.                nop(); exec = 0; execmsg(480, 190, col0);
  1107.                continue;
  1108.             }
  1109.             if (com ==11) { deinit(); system("command.com"); init(); break; }
  1110.             if (com == 0) { deinit();  exit(0); }
  1111.          }
  1112.          while ((MOS_rdpos(&mx, &my) & 0x01) == 0);
  1113.          if (calchk(mx, my, 600, 30, &mosx, &mosy) == 1) continue;
  1114.          if (wabotchk(mx, my, 600, 60) == 1) continue;
  1115.          if (xychk16(mx, my, 96, 70) == 1) com = 1;
  1116.          if (xychk16(mx, my, 96, 90) == 1) com = 2;
  1117.          if (xychk16(mx, my, 96,110) == 1) com = 3;
  1118.          if (xychk16(mx, my, 96,130) == 1) com = 4;
  1119.          if (xychk16(mx, my, 96,150) == 1) com = 5;
  1120.          if (xychk16(mx, my, 96,170) == 1) com = 6;
  1121.          if (xychk16(mx, my,336, 70) == 1) com = 7;
  1122.          if (xychk16(mx, my,336,150) == 1) com =11;
  1123.          if (xychk16(mx, my,336,170) == 1) com = 0;
  1124.          if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
  1125.             execmsg(480, 190, -1);
  1126.             while ((MOS_rdpos(&mx, &my) & 0x01) == 1);
  1127.             if (xychk(mx, my,480,190, 480+33, 190+18) == 1) {
  1128.                exec = 1;
  1129.                continue;
  1130.             } else {
  1131.                exec = 0;
  1132.                execmsg(480, 190, col0);
  1133.                continue;
  1134.             }
  1135.          }
  1136.          if (com != com2) {
  1137.             if (com2 == 1) { msgset( 96, 70, "●", col7); msgset( 96, 70, "○", col0); }
  1138.             if (com2 == 2) { msgset( 96, 90, "●", col7); msgset( 96, 90, "○", col0); }
  1139.             if (com2 == 3) { msgset( 96,110, "●", col7); msgset( 96,110, "○", col0); }
  1140.             if (com2 == 4) { msgset( 96,130, "●", col7); msgset( 96,130, "○", col0); }
  1141.             if (com2 == 5) { msgset( 96,150, "●", col7); msgset( 96,150, "○", col0); }
  1142.             if (com2 == 6) { msgset( 96,170, "●", col7); msgset( 96,170, "○", col0); }
  1143.             if (com2 == 7) { msgset(336, 70, "●", col7); msgset(336, 70, "○", col0); }
  1144.             if (com2 ==11) { msgset(336,150, "●", col7); msgset(336,150, "○", col0); }
  1145.             if (com2 == 0) { msgset(336,170, "●", col7); msgset(336,170, "○", col0); }
  1146.             hmsgset(com2, 0);
  1147.             com2 = com;
  1148.          }
  1149.       }
  1150.    }
  1151. }
  1152.  
  1153.